As a conventional method of producing an optical element, there is a known method in which a formed layer to be provided with an optical function part such as a grating is formed in the depression of a base by pressing a forming mold against a resin material arranged in the depression of the base and curing the resin material (for example, see Patent Literatures 1 to 5).